package com.shir.travels.ui.main;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.baronzhang.android.weather.WelcomeActivity;
import com.baronzhang.android.weather.feature.home.MainActivity;
import com.bumptech.glide.Glide;
import com.shir.travels.R;
import com.shir.travels.ui.gonglue.GongLue;
import com.shir.travels.ui.jiaotong.Traffic;
import com.shir.travels.ui.keliu.KeLiu;
import com.shir.travels.ui.tuisong.TuiSong;
import com.shir.travels.ui.user_pic.UserPic;
import com.shir.travels.ui.yulun.YuLun;
import com.shir.travels.ui.zhoubian.ZhouBian;
import com.stx.xhb.xbanner.XBanner;
import com.stx.xhb.xbanner.transformers.Transformer;

import java.util.ArrayList;
import java.util.List;


public class MainPage extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // click activities
        ImageView imageView = (ImageView)findViewById(R.id.imageView3); // 用户画像
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(MainPage.this, UserPic.class);
                startActivity(intent);
            }
        });

        ImageView imageView1 = (ImageView)findViewById(R.id.imageView4); // 定制攻略
        imageView1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(MainPage.this, GongLue.class);
                startActivity(intent);
            }
        });

        ImageView imageView2 = (ImageView)findViewById(R.id.imageView5); // 流量检测
        imageView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(MainPage.this, KeLiu.class);
                startActivity(intent);
            }
        });

        ImageView imageView3 = (ImageView)findViewById(R.id.imageView6); //舆论
        imageView3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(MainPage.this, YuLun.class);
                startActivity(intent);
            }
        });

        ImageView imageView4 = (ImageView)findViewById(R.id.imageView7); // 推送
        imageView4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(MainPage.this, TuiSong.class);
                startActivity(intent);
            }
        });

        ImageView imageView5 = (ImageView)findViewById(R.id.imageView8); // 天气
        imageView5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(MainPage.this, WelcomeActivity.class);
                startActivity(intent);
            }
        });

        ImageView imageView6 = (ImageView)findViewById(R.id.imageView9); // 交通
        imageView6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(MainPage.this, Traffic.class);
                startActivity(intent);
            }
        });

        ImageView imageView7 = (ImageView)findViewById(R.id.imageView10); // 周边游
        imageView7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(MainPage.this, ZhouBian.class);
                startActivity(intent);
            }
        });

        // set xbanner
        XBanner xBanner = (XBanner)findViewById(R.id.xbanner);
        final List<Integer> imageIds = new ArrayList<>();
        List<String> titles = new ArrayList<>();
        imageIds.add(R.drawable.scene_luoxin);
        titles.add("裸心堡");
        imageIds.add(R.drawable.scene_national_park);
        titles.add("湿地公园");
        imageIds.add(R.drawable.scene_sword_pool);
        titles.add("剑池");
        imageIds.add(R.drawable.scene_villege_yu);
        titles.add("渝村");
        imageIds.add(R.drawable.scene_xinshi_town);
        titles.add("新市古镇");
        xBanner.setData(imageIds,titles);
        xBanner.setmAdapter(new XBanner.XBannerAdapter(){
            @Override
            public void loadBanner(XBanner banner, Object model, View view, int position) {
                Glide.with(MainPage.this).load(imageIds.get(position)).into((ImageView)view);
            }
        });
        xBanner.setPageTransformer(Transformer.Default);
        xBanner.setPageChangeDuration(1000);

    }
}
